/**
 * 用户详情对话框
 */
var UserInfoDlg = {
    data: {
        deptId: "1111",
        deptName: ""
    }
};

layui.use(['layer', 'form', 'admin', 'laydate', 'ax', 'formSelects','element'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;
    var layer = layui.layer;
    var formSelects = layui.formSelects;
    var element = layui.element;




    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/share/copySchedule" ,function (data) {

            //400错误合成失败
            if (data.code ==400){
                alert(data.message+'!!!'+JSON.stringify(data.data));

                $.ajax({
                    url:Feng.ctxPath + "/share/test1",
                    data:data.data,
                    dataType:'json',
                    success:function (result) {
                        parent.layer.open({
                            type: 1,
                            title:'选择需要的日程项',
                            area: ['90%', '95%'],
                            fixed: false, //不固定
                            maxmin: true,
                            // content: '<div id="output_detail" class="pace-done" style="padding: 40px;  line-height: 5px;" > <p style="word-wrap:break-word; word-break:break-all;">'+ '确定导出执行计划吗？' + '</p> <br><br><input type=checkbox name=details id=checkcheck>导出详情</label></div>',
                            content: result,
                            closeBtn : 1,
                        });
                    }
                });
                var htmlopen = '';
                for (var ele in data.data){
                    // alert(data.data[ele]);
                    htmlopen += '<div class="layui-card"><div class="layui-card-header">' + ele + '</div>';
                    htmlopen += '   <div class="layui-card-body">';
                    for (var value in data.data[ele]){

                        htmlopen += '<input class="abcx" type="checkbox" name="sex" lay-skin="primary" value="'+data.data[ele][value].scheduleitemId+'" title="'+data.data[ele][value].startTime+'-'+data.data[ele][value].endTime +'"/><br>';
                    }
                    htmlopen += '   </div>';
                    htmlopen += '</div>';
                    // htmlopen +=''
                    // htmlopen += '<div id="output_detail" class="pace-done" style="padding: 40px;  line-height: 5px;" > <p style="word-wrap:break-word; word-break:break-all;">'+ ele + '</p> <br><br>';
                    // htmlopen += '<input type=checkbox name=details id=checkcheck>导出详情</div>';
                }
                // parent.layer.open({
                //     type: 1,
                //     title:'选择需要的日程项',
                //     area: ['90%', '95%'],
                //     fixed: false, //不固定
                //     maxmin: true,
                //     // content: '<div id="output_detail" class="pace-done" style="padding: 40px;  line-height: 5px;" > <p style="word-wrap:break-word; word-break:break-all;">'+ '确定导出执行计划吗？' + '</p> <br><br><input type=checkbox name=details id=checkcheck>导出详情</label></div>',
                //     content: htmlopen,
                //     closeBtn : 1,
                //     btn : [ '确认','取消' ],
                //     yes:function(index, layero){
                //         // location.href="${ctx}/datavalid/planResult/export?id="+resultId+"&check="+$("#checkcheck").attr("checked");
                //         /*   $.ajax({
                //               method : "get",
                //               url : "${ctx}/datavalid/planResult/export?id="+resultId+"&check="+$("#checkcheck").attr("checked"),
                //               success : function(data) {
                //                     alert(data);
                //
                //                      }
                //                   });   */
                //         var abc = $(".abcx").attr("checked");
                //         alert(abc);
                //         parent.layer.closeAll();
                //         // layer.close(index);
                //     }
                // });

            } else {
                Feng.success("合成成功！");
                admin.closeThisDialog();
            }
            // alert(JSON.stringify(data))

        }, function (data) {
            Feng.error("合成失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();
        //刷新父页面
        // parent.location.reload();
        // 添加 return false 可成功跳转页面
        // layer.close(loadIndex);
        return false;
    });



    /**
     * 初始化日程框架
     */
    var otherOrMyself='';

    /**
     * 初始化日程
     * @param data
     */


    form.on('select(getFrame)', function(data) {
        $('#scheduleMessage').empty();
        if (data.value!='') {
            showFrame(data.value)
        }
    });

    alert();


});